namespace UmSoft.SharePoint.Integration._1Cv77
{
    using System;
    using UmSoft.SharePoint.Integration._1Cv77;

    public class V7Document : V7Object
    {
        public V7Document(V7Object obj)
            : base(obj)
        {
            if (Object == null)
                throw new ArgumentNullException("obj", "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440 \u043D\u0435 \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u0442 COM-\u043A\u043B\u0430\u0441\u0441\u0430");
     
        }
        public override string ToString()
        {
            return base.InvokeMethod("Вид",
                new object[0]).ToString();
        }
        public bool FindByNumber(string number, Nullable<System.DateTime> date)
        {
            return this.InvokeMethod("НайтиПоНомеру", new object[] { number, date }).Equals(V7.TRUE);

        }
        public bool FindDocument(V7Object document)
        {
            return base.InvokeMethod("НайтиДокумент",
                new object[] {
                        document.Object}).Equals(V7.TRUE);
        }
        public void New()
        {
            this.InvokeMethod("Новый", new object[0]);

        }
        public void NewLine()
        {
            base.InvokeMethod("НоваяСтрока",
                new object[0]);
        }
        public void Save()
        {
            this.InvokeMethod("Записать", new object[0]);

        }
        public void Delete(bool isMark)
        {
            base.InvokeMethod("Удалить",
                new object[] {
                        (isMark ? V7.TRUE : V7.FALSE)});
        }
        public void Delete()
        {
            this.Delete(true);
        }
        public void DeleteLine()
        {
            base.InvokeMethod("УдалитьСтроку",
                new object[0]);
        }
        public void DeleteLines()
        {
            this.InvokeMethod("УдалитьСтроки", new object[0]);

        }
        public bool Select(object beginDate, object endDate)
        {
            object obj;
            object obj1;
            obj = V7.FALSE;
            obj1 = V7.FALSE;
            if (!(((DateTime)beginDate)).Equals(0))
            {
                obj = Convert.ToDateTime(beginDate);
            }
            if (!(((DateTime)endDate)).Equals(0))
            {
                obj1 = Convert.ToDateTime(endDate);
            }
            return base.InvokeMethod("ВыбратьДокументы",
                new object[] {
                        obj,
                        obj1}).Equals(V7.TRUE);
        }
        public bool SelectLines()
        {
            return this.InvokeMethod("ВыбратьСтроки", new object[0]).Equals(V7.TRUE);
        }
        public bool GetLineByNumber(int number)
        {
            return base.InvokeMethod("ПолучитьСтрокуПоНомеру",
                new object[] {
                        number}).Equals(V7.TRUE);
        }
        public bool GetLine()
        {
            return this.InvokeMethod("ПолучитьСтроку", new object[0]).Equals(V7.TRUE);

        }
        public bool GetDocument()
        {
            return base.InvokeMethod("ПолучитьДокумент",
                new object[0]).Equals(V7.TRUE);
        }
        public virtual V7Object Current
        {
            get
            {
                if (this.IsSelect)
                {
                    return (this.InvokeMethod("ТекущийДокумент", new object[0]) as V7Object);
                }
                return null;

            }
        }
        public bool IsSelect
        {
            get
            {
                return base.InvokeMethod("Выбран",
                    new object[0]).Equals(V7.TRUE);
            }
        }
        public string Number
        {
            get
            {
                return this.GetProperty("НомерДок").ToString();
            }
            set
            {
                base.SetProperty("НомерДок", value);
            }
        }
        public DateTime Date
        {
            get
            {
                return Convert.ToDateTime(this.GetProperty("ДатаДок"));

            }
            set
            {
                base.SetProperty("ДатаДок", value);
            }
        }
        protected int LineNumber
        {
            get
            {
                return Convert.ToInt32(this.GetProperty("НомерСтроки"));

            }
        }
        protected int LineCount
        {
            get
            {
                return Convert.ToInt32(base.InvokeMethod("КоличествоСтрок",
                        new object[0]));
            }
        }
        public bool IsTransacted
        {
            get
            {
                return this.InvokeMethod("Проведен", new object[0]).Equals(V7.TRUE);

            }
        }
        public virtual V7Object this[string number, DateTime date]
        {
            get
            {
                if (!FindByNumber(number, new Nullable<System.DateTime>(date)))
                {
                    return null;
                }
                else
                {
                    return Current;
                }
            }
        }
    }
}
